package com.example.springboot.utils;

import com.example.springboot.bean.HttpResult;

/**
 * Created by wuning at 2018/9/10 14:58
 **/
public class ResultUtil {

    private ResultUtil(){}
    private final static class Holder{
        private final static ResultUtil ins = new ResultUtil();
    }

    public static ResultUtil get(){
        return Holder.ins;
    }
    /**
     * 请求成功返回
     * @param object
     * @return
     */
    public HttpResult success(Object object){
        HttpResult Result=new HttpResult();
        Result.setCode(200);
        Result.setMsg("success");
        Result.setData(object);
        return Result;
    }

    public HttpResult success(){
        return success(null);
    }

    public HttpResult error(Integer code,String msg){
        HttpResult Result=new HttpResult();
        Result.setCode(code);
        Result.setMsg(msg);
        return Result;
    }
}
